﻿
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
namespace SMSPanasonic.Business
{
    public partial class pa_AgencyPhone
    {
    	#region public properties
		public int AgencyID { get; set; }
		public string Phone { get; set; }
		public bool? Disabled { get; set; }
		#endregion

		#region constructor
		public pa_AgencyPhone(){ }

		public pa_AgencyPhone(IDataReader rd)
		{
			this.AgencyID = (int)rd["AgencyID"];
			this.Phone = rd["Phone"].ToString();
			this.Disabled = rd["Disabled"].Equals(DBNull.Value) ? (bool?)null : (bool)rd["Disabled"];
		}
		#endregion


		#region static method
        public static pa_AgencyPhone GetOne(string phone)
        {
            using (SqlDataReader rd = SqlHelper.ExecuteReader(AppConfig.ConnectionString, CommandType.Text,
                        "SELECT * FROM pa_AgencyPhone WHERE Phone = @Phone", new SqlParameter("@Phone", phone)))
            {
                while (rd.Read())
                {
                    return new pa_AgencyPhone(rd);
                }
                return null;
            }
        }
		#endregion
	}
}
